13. Testing the Room Database
L6 23 Test The Room Database SC
Now it's your turn to run the test yourself.
In this step, you'll try out code for testing your Room database.
Use the solution code from the previous exercise, which you can download here: Step.03-Solution-Create-RoomDatabase. Work from that code, or copy the test file to your code.
In the
androidTestfolder, open theSleepDatabaseTestfile.Uncomment the code.
Right-click on the test file in the Project view and choose Run.
After the app builds and runs, verify in the
SleepDatabaseTestpane that all the tests have passed.
Bonus Exercise: Add tests to exercise the other DAO methods. There is no solution code provided for this optional challenge. You can use the Testing Training in the Android Developer Documentation to dive deeper.
Task Description:
Complete these tasks to test your Room database.
Task Feedback:
Do you feel reassured?
Reference documentation